<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>
<html>
	<head>
		<script language="javascript" src="<%=contextPath%>/js/func.js"type=""></script>
		<script type="text/javascript" src="<%=contextPath%>/js/validator.js"></script> 
		<script type="text/javascript" src="<%=contextPath%>/ext3/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="<%=contextPath%>/ext3/ext-all.js"></script>
		<link rel="stylesheet" type="text/css"	href="<%=contextPath%>/ext3/resources/css/ext-all.css">
		<script>
			Ext.onReady(function(){
				var tb = new Ext.Toolbar({
			   		renderTo: document.all.tbar,
			    	items: [
				        {
				            text: '保存',
							cls:'x-btn-text-icon',
            				icon:'<%=contextPath%>/images/save.gif',
				            handler:comt,
				            hidden:<%=session.getAttribute("btn_saverw_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>
				        },'-',
				        {
				            text: '删除',
				            cls:'x-btn-text-icon',
				            icon:"<%=contextPath%>/images/delete.gif",
				            handler:deleteIt,
				            hidden:<%=session.getAttribute("btn_deleterw_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>
				        }
			    	]
			    });
			});
		</script>
	<base target="_self" />
	<body onload="toDetail('0','','','','')">
		
		<div id = "tbar" style="position:absolute;display:block left:0px; top:0px; width:100%; height:35px; z-index:1;"></div>
		<div id="Layer" style="position:absolute;display:block left:0px; top:35px; width:100%; height:90%; z-index:1000; overflow:auto;">
			<form id="frmM" name="frmM" method="POST" action="<%=contextPath%>/queryUser.do">	
				<s:hidden name="rw.id"/>
				<s:hidden name="rw.bdz"/>
				<s:hidden name="rw.ouid"/>
                <s:hidden name="rw.sfwc"/>
			<table width="100%" id="infotab">
				<!--<tr>
					<th width="120" >
						<font color="red">*</font>&nbsp;变电站：
					</th>
					
					<td nowrap colspan="3">
						<input type="text" readonly="true" style="width:97%" name="rw.bdzname" value="${rw.bdzname}" msg="变电站必须输入。" size="25"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="选择变电站" onClick="javascript:getBdz('rw.bdz','rw.bdzname','rw.ouid')" />
					</td>
					
				</tr>
				-->
				<tr>
					<th width="120" nowrap>
						<font color="red">*</font>&nbsp;工作任务：
					</th>
					<td colspan="3">
						<input type="text" style="width:97%" datatype="Require" name="rw.rwnr" value="${rw.rwnr}" msg="工作任务必须输入。" maxlength="250"/>
					</td>
				</tr>
			</table>	
			<br>

			<table width="100%" id="listtab">
				<tr>
					<th width="25">
						<input name="chkAll" type="checkbox" id="chkAll"
							onclick="javascript:checkAll(this.form, 'id');" value="checkbox">
					</th>
					<!--<td width="200">变电站</td>-->
					<th nowrap>工作任务</th>
					<th width="60">是否完成</th>
				</tr>
				
				<c:forEach items="${rwList}" var="rw" >
					<tr>
						<td width="25">
							<input type="checkbox" name="id" value="${rw.id}" />
						<br></td>
						<!--<td width="200">
							<a href="#" onClick="javascript:toDetail('<c:out value="${rw.id}"/>','<c:out value="${rw.rwnr}"/>','<c:out value="${rw.bdz}"/>','<c:out value="${rw.bdzname}"/>','<c:out value="${rw.ouid}"/>')" >${rw.bdzname}</a></td>
						-->
						<td>
							<a href="#" onClick="javascript:toDetail('<c:out value="${rw.id}"/>','<c:out value="${rw.rwnr}"/>','<c:out value="${rw.bdz}"/>','<c:out value="${rw.bdzname}"/>','<c:out value="${rw.ouid}"/>')" >${rw.rwnr}</a></td>
					<td>
					<select name="sfwc" >
							<c:choose>
								<c:when test="${rw.sfwc == '' || rw.sfwc == null}">
									<option value="" selected></option>
									<option value="0">否</option>
									<option value="1">是</option>
								</c:when>
								<c:when test="${rw.sfwc == '0'}">
									<option value="" ></option>
									<option value="0" selected>否</option>
									<option value="1">是</option>
								</c:when>
								<c:when test="${rw.sfwc == '1'}">
									<option value="" ></option>
									<option value="0">否</option>
									<option value="1" selected>是</option>
								</c:when>
							</c:choose>
							</select></td>
					</tr>
				</c:forEach>

			</table>

			</form>
		</div>
	</body>
</html>
<script language="javascript">

			// 
			function toDetail(id, rwnr, bdz, bdzname, ouid) {
			
			try{
				document.frmM.elements["rw.id"].value = id;
				document.frmM.elements["rw.rwnr"].value = rwnr;
				//document.frmM.elements["rw.bdz"].value = bdz;
				//document.frmM.elements["rw.bdzname"].value = bdzname;
				document.frmM.elements["rw.ouid"].value = ouid;			
				//document.frmM.elements["rw.sfwc"].value = document.getElementById("sfwc").options[document.getElementById("sfwc").selectedIndex].value;
				}catch (e){
					alert(e);
				}	
			}

			 // 保存
    		 function comt(){
    		 	
    		 	if (parent.document.frmM.elements["entity.id"].value == 0) {
    		 		alert("请先保存基本信息");
    		 		return;
    		 	}
    		 	
    		 	if (document.frmM.elements["rw.rwnr"].value == "") {
    		 		alert("任务必须输入");
    		 		return;
    		 	}
    		 		
     			document.frmM.action = "<%=contextPath%>/gzrwd!saveRw.do";
     			document.frmM.submit();
     		}
     
     		// 删除
			function deleteIt()
			{
				if(!isChecked("id")) {
		 			alert("请选择要删除的记录");
		 			return false;
		 		}
		    	if(confirm("删除工作任务将一同删除工作任务对应操作记录，确定要删除选中的记录吗？")) {

/*
				// 判断这个任务是否已经生成了任务
				Ext.Ajax.request({
					method :'POST',
					async: false,
					url : "<%=contextPath%>/dzczjl!checkJlByRw2.do",
					params:{rwid:document.getElementById("id").value},
					success : function(response) {
        				
        				var obj = Ext.decode(response.responseText);
        				
						if (obj["m"]  != undefined) {
        					alert("该工作任务已经起草过操作记录,不能删除。");
        					return false;
        				} else {
        				
		        			document.frmM.action = "<%=contextPath%>/gzrwd!deleteRw.do";
							document.frmM.submit();
							
        				}
						
					},
					failure : function() {
						alert("异步失败！");
							return false;
					}
				});
				
*/				
					document.frmM.action = "<%=contextPath%>/gzrwd!deleteRw.do";
					document.frmM.submit();

		    	}
			}
			
			// 选择一个任务ID，并返回该ID
			function getRwid() {
			
     			// 必须选中一个工作任务才能起草操作记录
     			if(!isChecked("id") || isCheckMany("id")) {
     				return "";
     	
     			} else {
     				return getCheckValue("id");
     			}
     		}	
     			
			
		</script>